//
//  WordsFinishView.m
//  LineByLine
//
//  Created by 병철 김 on 11. 11. 9..
//  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import "WordsFinishView.h"
#import "CommonDefine.h"


@implementation WordsFinishView
@synthesize timeInterval;

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self setBackgroundColor:[UIColor grayColor]];
        UIView *timeBackView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kContentWidth, 76)];
        timeView = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 200, 56)];
        
        [timeBackView setBackgroundColor:[UIColor yellowColor]];
        
        [timeView setFont:[UIFont fontWithName:@"DBLCDTempBlack" size:36]];
        [timeView setTextColor:[UIColor blackColor]];
        [timeView setBackgroundColor:[UIColor clearColor]];
                           
        [timeBackView addSubview:timeView];
        [self addSubview:timeBackView];
        [timeBackView release];
        [timeView release];
    }
    return self;
}

- (void) show {
    [UIView beginAnimations:@"WordsFinishViewShow" context:nil];
    CGRect frame = [self frame];
    frame.origin.y = 100;
    [self setFrame:frame];
    [UIView commitAnimations];
}

- (void) hide {
    CGRect frame = [self frame];
    frame.origin.y = -72;
    [self setFrame:frame];
}

- (void) configView {
    NSDate *time = [NSDate dateWithTimeIntervalSince1970:timeInterval];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"mm:ss.SSS"];
    NSString *timeString = [formatter stringFromDate:time];
    [timeView setText:timeString];
    [formatter release];
}
@end
